﻿using Coldairarrow.Business.Foot;
using Coldairarrow.Entity.Foot;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.backstage
{
    [Route("/backstage/[controller]/[action]")]
    public class BKS_ManageController : BaseApiController
    {
        #region DI

        public BKS_ManageController(IFoot_ManageBusiness foot_ManageBus)
        {
            _foot_ManageBus = foot_ManageBus;
        }

        IFoot_ManageBusiness _foot_ManageBus { get; }

        #endregion

        #region 获取

        /// <summary>
        /// 查询指定导航栏的数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List< Foot_Manage>> GetTheData(IdInputDTO input)
        {
            return await _foot_ManageBus.GetTheDataAsync(input.id);
        }
        /// <summary>
        /// 查询所有底部导航栏
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public List<Foot_Manage> All()
        {
            return  _foot_ManageBus.All();
        }
        /// <summary>
        /// 查询所有底部导航栏
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task< List<Foot_Manage>> TwoAll()
        {
            return await _foot_ManageBus.TwoAll();
        }
        #endregion

        #region 提交
        /// <summary>
        /// 添加或修改底部导航栏
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveData(Foot_Manage data)
        {
            if (data.id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _foot_ManageBus.AddDataAsync(data);
            }
            else
            {
                await _foot_ManageBus.UpdateDataAsync(data);
            }
        }
        /// <summary>
        /// 删除对应的底部导航栏
        /// </summary>
        /// <param name="ids">底部导航栏的id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _foot_ManageBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}